<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ include file="/WEB-INF/view/include/inc.jsp"%>
<!DOCTYPE html>
<html lang="en">
<head>
 	<%@ include file="/WEB-INF/view/jQgrid.jsp"%>
</head>
<body>
<div class="container-fluid" id="main-container">
    <div id="page-content" class="clearfix">
        <div class="row-fluid">
            <div class="row-fluid">
                <!-- 检索  -->
                <div class="ibox-title" style="border-color: white;">
	                <div class="row form-inline">
                       <div class="col-sm-4" >
                           <div class="form-group" >
                               <span>姓名:</span>
                               <input id="name" type="text" placeholder="请输入简历姓名" class="input-sm form-control"  value="${trueName }"/>
                            </div>
                       </div>
                       <div class="col-sm-5" >
                           <div class="form-group" >
                               <span>目前岗位:</span>
                               <input id="position" type="text" placeholder="请输入目前岗位" class="input-sm form-control"  value="${position }"/>
                               
                            </div>
                       </div>
                        <div class="col-sm-3" >
                           <div class="form-group" >
                                <a id="find_btn" type="button" class="btn btn-sm btn-primary"> 搜索</a> &nbsp;&nbsp;
                      		     <a  class="btn btn-sm btn-warning"  onclick="reset();"> 重置</a>&nbsp;&nbsp;
                      		     <a id="sub_btn" class="btn btn-sm btn-success" > 确认</a>
                            </div>
                       </div>
                   </div>
                </div>
                <!-- biaogebigin -->
                <input type="hidden" id="tempids" value="" />
		        <input type="hidden" id="tempnames" value="" />
                <div class="ibox-content" style=" padding-left: 0px; margin-top: 10px;">
                    <div class="jqGrid_wrapper">
                        <table id="table_list"></table>
                        <div id="pager_list"></div>
                    </div>
                </div>
                <!-- tableover -->
            </div>
            <!-- PAGE CONTENT ENDS HERE -->

        </div>
        <!--/row-->
    </div>
    <!--/#page-content-->
</div>
<!--/.fluid-container#main-container-->
<script type="text/javascript">
    var name = $("#name").val();
    var position = $("#position").val();
        $.jgrid.defaults.styleUI = "Bootstrap";
        $("#table_list").jqGrid({
            url: '<%=contextPath%>/resume/listData',
            datatype: "json",
            postData: {'name':name,'position':position}, //发送数据
            autowidth: true,
            rownumbers: true,
            shrinkToFit: true,
            mtype: "post",
            rowNum: 10,
            rowList: [10, 20, 30],
            colNames: ["id","姓名","性别","学历","手机","行业","目前岗位","目前薪酬","操作"],
            colModel: [{
                name: "id",
                index: "id",
                hidden: true
            }, {
                name: "trueName",
                index: "trueName",
                width: 50,
                frozen : true
            }, {
                name: "sex",
                index: "sex",
                width: 50,
                formatter: function (value, options, row) {
                	if(value ==1){
                		return "男";
                	}
                	if(value ==2){
                		return "女";
                	}
                }
            }, {
                name: "education",
                index: "education",
                width: 60,
                frozen : true
            }, {
                name: "phoneview",
                index: "phoneview",
                width: 90,
                frozen : true
            }, {
                name: "industryNames",
                index: "industryNames",
                width: 100
            }, {
                name: "position",
                index: "position",
                width: 100
            },{
                name: "emolument",
                index: "emolument",
                width: 80,
                formatter: function (value, options, row) {
                	return "￥"+value+"万"
                }
            }, {
                formatter: function (cellvalue, options, row) {
                    return "<s:hasPermission name="resume:detail"><a class='btn btn-mini btn-success' title='查看' onclick='showdetail(&quot;" + row.id + "&quot;)'><i class='icon-eye-open'></i></a></s:hasPermission> ";
                },
                width: 50
            }],
            height: $(window).height() - 170,
            pager: "#pager_list",
            multiselect: true,//多选按钮
            //multiboxonly: true,
            viewrecords: true,
            hidegrid: false
        });
        //表格自适应高宽
        $(window).bind("resize", function () {
            var b = $(".jqGrid_wrapper").width();
            $("#table_list").setGridWidth(b);
            $("#table_list").setGridHeight($(window).height() - 170);
        })
        $("#table_list").navGrid('#pager_list', {edit: false, add: false, del: false, search: false})
        /* 判断是否有添加权限 */
        //检索
        $("#find_btn").click(function () {
        	name = $("#name").val();
        	position = $("#position").val();
            $("#table_list").jqGrid('setGridParam', {
                postData: {'name': name,'position':position}, //发送数据
                page: 1
            }).trigger("reloadGrid"); //重新载入
        });
        //查看
        function showdetail(id) {
        	window.open("<%=contextPath%>/resume/detailView?id=" + id);
        }
        $("#sub_btn").click(function() {
        	var selectedIds = $("#table_list").jqGrid("getGridParam", "selarrrow");
        	var tempid="";
        	var tempname="";
        	var rowdatas;
        	for (var i = 0; i < selectedIds.length; i++) {
        		rowdatas = $("#table_list").jqGrid("getRowData",selectedIds[i]);
        		tempid  += rowdatas.id;
        		tempname +=rowdatas.trueName;
        		if(i>0){
        			swal({
      	    			title:"请选择一条简历数据",
      	    			text: "1秒后自动关闭。", 
      	    			timer: 1000, 
      				    showConfirmButton: false
      	    		});
        			return;
        		}
			}
        	if(tempid==""){
        		swal({
  	    			title:"请选择一条数据",
  	    			text: "1秒后自动关闭。", 
  	    			timer: 1000, 
  				    showConfirmButton: false
  	    		});
        	}else {
        		$("#tempids").val(tempid);
            	$("#tempnames").val(tempname);
        		top.Dialog.close();
			}
		});
       function reset() {
		$("#name").val('');
		$("#position").val('');
       }
</script>
</body>
</html>

